home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWLocale.z / RWLocale
Encoding:
Text File  |  1998-10-30  |  21.8 KB  |  463 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))                                                  RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWLocale - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <locale.h>
  13.           #include <rw/locale.h>
  14.           ((((AAAAbbbbssssttttrrrraaaacccctttt bbbbaaaasssseeee ccccllllaaaassssssss))))
  15.  
  16.  
  17.  
  18. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  19.      RRRRWWWWLLLLooooccccaaaalllleeee is an abstract base class.  It defines an interface for
  20.      formatting dates (including day and month names), times, numbers
  21.      (including digit grouping), and currency, to and from strings. Note that
  22.      because it is an aaaabbbbssssttttrrrraaaacccctttt base class, there is no way to actually enforce
  23.      these goals -- the description here is merely the model of how a class
  24.      derived from RRRRWWWWLLLLooooccccaaaalllleeee should act.  There are three ways to use an
  25.      RRRRWWWWLLLLooooccccaaaalllleeee object:
  26.           By passing the object to functions which expect one, such as
  27.           RRRRWWWWDDDDaaaatttteeee::::::::aaaassssSSSSttttrrrriiiinnnngggg(((())))....
  28.  
  29.           By specifying a "global" locale using the static member function
  30.           RRRRWWWWLLLLooooccccaaaalllleeee::::::::gggglllloooobbbbaaaallll((((RRRRWWWWLLLLooooccccaaaalllleeee****))))....  This locale is passed as the default
  31.           argument to functions that use a locale.
  32.  
  33.           By "imbuing" a stream with the object, so that when an RRRRWWWWDDDDaaaatttteeee or
  34.           RRRRWWWWTTTTiiiimmmmeeee is written to a stream using ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(((()))), the appropriate
  35.           formatting will be used automatically.
  36.  
  37.      Two implementations of RRRRWWWWLLLLooooccccaaaalllleeee are provided with the library:
  38.           Class RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt encapsulates the Standard C library locale
  39.           facility, with two additional advantages: more than one locale can
  40.           be active at the same time; and it supports conversions ffffrrrroooommmm strings
  41.           to other types.  .in -5
  42.  
  43.                There is also an internal class that mimics
  44.                RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((""""CCCC"""")))).  If your compiler does not have built-in
  45.                support for locales, one is constructed automatically at
  46.                program startup to be used as the default value of
  47.                RRRRWWWWLLLLooooccccaaaalllleeee::::::::gggglllloooobbbbaaaallll(((()))).  If your compiler does support locales,
  48.                RRRRWWWWLLLLooooccccaaaalllleeee::::::::gggglllloooobbbbaaaallll(((()))) returns a const reference to an instance of
  49.                RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((""""CCCC""""))))..in -5
  50.  
  51.  
  52. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  53.      None
  54.  
  55. EEEEnnnnuuuummmmeeeerrrraaaattttiiiioooonnnn
  56.               enum
  57.           CCCCuuuurrrrrrrrSSSSyyyymmmmbbbboooollll { NONE, LOCAL, INTL };
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))                                                  RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.      Controls whether no currency symbol, the local currency symbol, or the
  75.      international currency symbol should be used to format currency.
  76.  
  77. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  78.               virtual RWCString
  79.           aaaassssSSSSttttrrrriiiinnnngggg(long) const = 0;
  80.           virtual RWCString
  81.           aaaassssSSSSttttrrrriiiinnnngggg(unsigned long) const = 0;
  82.  
  83.  
  84.      Converts the number to a string (eeee....gggg...., """"3333,,,,444455556666"""").
  85.  
  86.               virtual RWCString
  87.           aaaassssSSSSttttrrrriiiinnnngggg(double f, int precision = 6,
  88.           RWBoolean showpoint = 0) const = 0;
  89.  
  90.  
  91.      Converts the ddddoooouuuubbbblllleeee ffff to a string.  The variable pppprrrreeeecccciiiissssiiiioooonnnn is the number
  92.      of digits to place after the decimal separator.  If sssshhhhoooowwwwppppooooiiiinnnntttt is TTTTRRRRUUUUEEEE,
  93.      the decimal separator will appear regardless of the precision.
  94.  
  95.               virtual RWCString
  96.           aaaassssSSSSttttrrrriiiinnnngggg(const struct tm* tmbuf,char format,
  97.           const RWZone& zone) const = 0;
  98.  
  99.  
  100.      Converts components of the ssssttttrrrruuuucccctttt ttttmmmm object to a string, according to the
  101.      format character.  The meanings assigned to the format character are
  102.      identical to those used in the Standard C Library function ssssttttrrrrffffttttiiiimmmmeeee(((()))).
  103.      The members of ssssttttrrrruuuucccctttt ttttmmmm are assumed to be set consistently.  See  for a
  104.      summary of ssssttttrrrrffffttttiiiimmmmeeee(((()))) formatting characters.
  105.  
  106.               RWCString
  107.           aaaassssSSSSttttrrrriiiinnnngggg(const struct tm* tmbuf,const char* format,
  108.                    const RWZone& zone) const;
  109.  
  110.  
  111.      Converts components of the ssssttttrrrruuuucccctttt ttttmmmm object to a string, according to the
  112.      format string.  Each format character in the format string must be
  113.      preceded by %%%%.  Any characters not preceded by %%%% are treated as ordinary
  114.      characters which are returned unchanged.  You may represent the special
  115.      character %%%% with "%%%%%%%%". The meanings assigned to the format character are
  116.      identical to those used in the Standard C Library function ssssttttrrrrffffttttiiiimmmmeeee(((()))).
  117.      The members of ssssttttrrrruuuucccctttt ttttmmmm are assumed to be set consistently.  See  for a
  118.      summary of ssssttttrrrrffffttttiiiimmmmeeee(((()))) formatting characters.  This function is not
  119.      virtual in order to maintain link-compatibility with the previous version
  120.      of the library.
  121.  
  122.               virtual RWCString
  123.           mmmmoooonnnneeeeyyyyAAAAssssSSSSttttrrrriiiinnnngggg(double value,enum CurrSymbol = LOCAL)
  124.                         const = 0;
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))                                                  RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      Returns a string containing the vvvvaaaalllluuuueeee argument formatted according to
  141.      monetary conventions for the locale.  The vvvvaaaalllluuuueeee argument is assumed to
  142.      contain an integer representing the number of units of currency (eeee....gggg....,
  143.      mmmmoooonnnneeeeyyyyAAAAssssSSSSttttrrrriiiinnnngggg((((1111000000000000....,,,, RRRRWWWWLLLLooooccccaaaalllleeee::::::::LLLLOOOOCCCCAAAALLLL)))) in a US locale would yield
  144.      "$$$$11110000....00000000").  The CCCCuuuurrrrrrrrSSSSyyyymmmmbbbboooollll argument determines whether the local (eeee....gggg....,
  145.      "$$$$") or international (eeee....gggg...., "UUUUSSSSDDDD ") currency symbol is applied, or none.
  146.  
  147.               virtual int
  148.           mmmmoooonnnntttthhhhIIIInnnnddddeeeexxxx(const RWCString&) const = 0;
  149.  
  150.  
  151.      Interprets its argument as a full or abbreviated month name, returning
  152.      values 1 through 12 to represent (respectively) January through December,
  153.      or 0 for an error.  Leading white space is ignored.
  154.  
  155.               virtual RWBoolean
  156.           ssssttttrrrriiiinnnnggggTTTTooooNNNNuuuummmm(const RWCString&, double* fp) const = 0;
  157.  
  158.  
  159.      Interprets the RRRRWWWWCCCCSSSSttttrrrriiiinnnngggg argument as a floating point number.  Spaces are
  160.      allowed before and after the (optional) sign, and at the end.  Digit
  161.      group separators are allowed in the integer portion.  Returns TTTTRRRRUUUUEEEE for a
  162.      valid number, FFFFAAAALLLLSSSSEEEE for an error.  If it returns FFFFAAAALLLLSSSSEEEE, the ddddoooouuuubbbblllleeee****
  163.      argument is untouched.  All valid numeric strings are accepted; all
  164.      others are rejected.  The following are examples of valid numeric strings
  165.      in an English-speaking locale:
  166.  
  167.                    "1"          " -02. "     ".3"
  168.  
  169.  
  170.  
  171.                    "1234.56"    "1e10"       "+ 19,876.2E+20"
  172.  
  173.  
  174.  
  175.  
  176.           virtual RWBoolean
  177.           ssssttttrrrriiiinnnnggggTTTTooooNNNNuuuummmm(const RWCString&, long* ip) const = 0;
  178.  
  179.  
  180.      Interprets the RRRRWWWWCCCCSSSSttttrrrriiiinnnngggg argument as an integer.  Spaces are allowed
  181.      before and after the (optional) sign, and at the end.  Digit group
  182.      separators are allowed.  Returns TTTTRRRRUUUUEEEE for a valid integer, FFFFAAAALLLLSSSSEEEE for an
  183.      error.  If it returns FFFFAAAALLLLSSSSEEEE, the lllloooonnnngggg**** argument is untouched.  All valid
  184.      numeric strings are accepted; all others are rejected.  The following are
  185.      examples of valid integral strings in an English-speaking locale:
  186.  
  187.                    "1"           " -02. "     "+ 1,234"
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))                                                  RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.                    "1234545"     "1,234,567"
  207.  
  208.  
  209.      Table 1. Formatting characters used by strftime().  EEEExxxxaaaammmmpppplllleeeessss aaaarrrreeee ggggiiiivvvveeeennnn
  210.      ((((iiiinnnn ppppaaaarrrreeeennnntttthhhheeeessssiiiissss)))).... FFFFoooorrrr tttthhhhoooosssseeee ffffoooorrrrmmmmaaaattttssss tttthhhhaaaatttt ddddoooo nnnnooootttt uuuusssseeee aaaallllllll mmmmeeeemmmmbbbbeeeerrrrssss ooooffff tttthhhheeee
  211.      ssssttttrrrruuuucccctttt ttttmmmm,,,, oooonnnnllllyyyy tttthhhhoooosssseeee mmmmeeeemmmmbbbbeeeerrrrssss tttthhhhaaaatttt aaaarrrreeee aaaaccccttttuuuuaaaallllllllyyyy uuuusssseeeedddd aaaarrrreeee nnnnooootttteeeedddd [[[[iiiinnnn
  212.      bbbbrrrraaaacccckkkkeeeettttssss]]]]....
  213.  
  214.  
  215.      FFFFoooorrrrmmmmaaaatttt cccchhhhaaaarrrraaaacccctttteeeerrrr MMMMeeeeaaaannnniiiinnnngggg EEEExxxxaaaammmmpppplllleeee
  216.  
  217.  
  218.      aaaa Abbreviated weekday name [from ttttmmmm::::::::ttttmmmm____wwwwddddaaaayyyy] SSSSuuuunnnn
  219.  
  220.  
  221.      AAAA Full weekday name [from ttttmmmm::::::::ttttmmmm____wwwwddddaaaayyyy] SSSSuuuunnnnddddaaaayyyy
  222.  
  223.  
  224.      bbbb Abbreviated month name FFFFeeeebbbb
  225.  
  226.  
  227.      BBBB Full month name FFFFeeeebbbbrrrruuuuaaaarrrryyyy
  228.  
  229.  
  230.      cccc Date and time [may use all members] FFFFeeeebbbb 22229999 11114444::::33334444::::55556666 1111999988884444
  231.  
  232.  
  233.      dddd Day of the month 22229999
  234.  
  235.  
  236.      HHHH Hour of the 24-hour day 11114444
  237.  
  238.  
  239.      IIII Hour of the 12-hour day 00002222
  240.  
  241.  
  242.      jjjj Day of the year, from 001 [from ttttmmmm::::::::ttttmmmm____yyyyddddaaaayyyy] 66660000
  243.  
  244.  
  245.      mmmm Month of the year, from 01 00002222
  246.  
  247.  
  248.      MMMM Minutes after the hour 33334444
  249.  
  250.  
  251.      pppp AM/PM indicator, if any AAAAMMMM
  252.  
  253.  
  254.      SSSS Seconds after the minute 55556666
  255.  
  256.  
  257.      UUUU Sunday week of the year, from 00 [from ttttmmmm::::::::ttttmmmm____yyyyddddaaaayyyy and ttttmmmm::::::::ttttmmmm____wwwwddddaaaayyyy]
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))                                                  RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.      wwww Day of the week, with 0 for Sunday 0000
  273.  
  274.  
  275.      WWWW Monday week of the year, from 00 [from ttttmmmm::::::::ttttmmmm____yyyyddddaaaayyyy and ttttmmmm::::::::ttttmmmm____wwwwddddaaaayyyy]
  276.  
  277.  
  278.      xxxx Date [uses ttttmmmm::::::::ttttmmmm____yyyyddddaaaayyyy in some locales] FFFFeeeebbbb 22229999 1111999988884444
  279.  
  280.  
  281.      XXXX Time 11114444::::33334444::::55556666
  282.  
  283.  
  284.      yyyy Year of the century, from 00 (deprecated) 88884444
  285.  
  286.  
  287.      YYYY Year 1111999988884444
  288.  
  289.  
  290.      ZZZZ Time zone name [from ttttmmmm::::::::ttttmmmm____iiiissssddddsssstttt] PPPPSSSSTTTT or PPPPDDDDTTTT
  291.  
  292.  
  293.           virtual RWBoolean
  294.           ssssttttrrrriiiinnnnggggTTTTooooDDDDaaaatttteeee(const RWCString&, struct tm*) const = 0;
  295.  
  296.  
  297.      Interprets the RRRRWWWWCCCCSSSSttttrrrriiiinnnngggg as a date, and extracts the month, day, and year
  298.      components to the ttttmmmm argument.  It returns TTTTRRRRUUUUEEEE for a valid date, FFFFAAAALLLLSSSSEEEE
  299.      otherwise.  If it returns FFFFAAAALLLLSSSSEEEE, the ssssttttrrrruuuucccctttt ttttmmmm argument is untouched;
  300.      otherwise it sets the ttttmmmm____mmmmddddaaaayyyy, ttttmmmm____mmmmoooonnnn, and ttttmmmm____yyyyeeeeaaaarrrr members.  If the date
  301.      is entered as three numbers, the order expected is the same as that
  302.      produced by ssssttttrrrrffffttttiiiimmmmeeee(((()))).  Note that this function cannot reject all
  303.      invalid date strings.  The following are examples of valid date strings
  304.      in an English-speaking locale:
  305.  
  306.                    "Jan 9, 62"     "1/9/62"     "January 9 1962"
  307.  
  308.  
  309.  
  310.                    "09Jan62"       "010962"
  311.  
  312.  
  313.  
  314.  
  315.               virtual RWBoolean
  316.           ssssttttrrrriiiinnnnggggTTTTooooTTTTiiiimmmmeeee(const RWCString&, struct tm*) const = 0;
  317.  
  318.  
  319.      Interprets the RRRRWWWWCCCCSSSSttttrrrriiiinnnngggg argument as a time, with hour, minute, and
  320.      optional second.  If the hour is in the range [1..12], the local
  321.      equivalent of "AM" or "PM" is allowed.  Returns TTTTRRRRUUUUEEEE for a valid time
  322.      string, FFFFAAAALLLLSSSSEEEE for an error.  If it returns FFFFAAAALLLLSSSSEEEE, the tm argument is
  323.      untouched; otherwise it sets the ttttmmmm____hhhhoooouuuurrrr, ttttmmmm____mmmmiiiinnnn, and ttttmmmm____sssseeeecccc members.
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))                                                  RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.      Note that this function cannot reject all invalid time strings.  The
  339.      following are examples of valid time strings in an English-speaking
  340.      locale:
  341.  
  342.                    "1:10 AM"     "13:45:30"     "12.30.45pm"
  343.  
  344.  
  345.  
  346.                    "PM 3:15"     "1430"
  347.  
  348.  
  349.  
  350.  
  351.               virtual RWBoolean
  352.           ssssttttrrrriiiinnnnggggTTTTooooMMMMoooonnnneeeeyyyy(const RWCString&, double*,
  353.                         RWLocale::CurrSymbol=LOCAL) const = 0;
  354.  
  355.  
  356.      Interprets the RRRRWWWWCCCCSSSSttttrrrriiiinnnngggg argument as a monetary value.  The currency
  357.      symbol, if any, is ignored.  Negative values may be specified by the
  358.      negation symbol or by enclosing parentheses.  Digit group separators are
  359.      optional; if present they are checked.  Returns TTTTRRRRUUUUEEEE for a valid monetary
  360.      value, FFFFAAAALLLLSSSSEEEE for an error.  If it returns FFFFAAAALLLLSSSSEEEE, the ddddoooouuuubbbblllleeee**** argument is
  361.      untouched; otherwise it is set to the integral number of monetary units
  362.      entered (e.g. cents, in a U.S. locale).
  363.  
  364.               const RWLocale*
  365.           iiiimmmmbbbbuuuueeee(ios& stream) const;
  366.  
  367.  
  368.      Installs self in the ssssttttrrrreeeeaaaammmm argument, for later use by the operators <<<<<<<<
  369.      and >>>>>>>> (e.g. in RRRRWWWWDDDDaaaatttteeee or RRRRWWWWTTTTiiiimmmmeeee).  The pointer may be retrieved from the
  370.      stream with the static member RRRRWWWWLLLLooooccccaaaalllleeee::::::::ooooffff(((()))).  In this way a locale may
  371.      be passed transparently through many levels of control to be available
  372.      where needed, without intruding elsewhere.
  373.  
  374.               virtual int
  375.           wwwweeeeeeeekkkkddddaaaayyyyIIIInnnnddddeeeexxxx(const RWCString&) const = 0;
  376.  
  377.  
  378.      Interprets its argument as a full or abbreviated weekday name, returning
  379.      values 1 through 7 to represent (respectively) Monday through Sunday, or
  380.      0 for an error.
  381.  
  382. SSSSttttaaaattttiiiicccc PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  383.               static const RWLocale&
  384.           ooooffff(ios&);
  385.  
  386.  
  387.      Returns the locale installed in the stream argument by a previous call to
  388.      RRRRWWWWLLLLooooccccaaaalllleeee::::::::iiiimmmmbbbbuuuueeee(((()))) or, if no locale was installed, the result from
  389.      RRRRWWWWLLLLooooccccaaaalllleeee::::::::gggglllloooobbbbaaaallll(((()))).
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))                                                  RRRRWWWWLLLLooooccccaaaalllleeee((((3333CCCC++++++++))))
  401.  
  402.  
  403.  
  404.               static const RWLocale*
  405.           gggglllloooobbbbaaaallll(const RWLocale* loc);
  406.  
  407.  
  408.      Sets the global "default" locale object to lllloooocccc, returning the old object.
  409.      This object is used by RRRRWWWWDDDDaaaatttteeee and RRRRWWWWTTTTiiiimmmmeeee string conversion functions as a
  410.      default locale.  It is set initially to refer to an instance of a class
  411.      that provides the functionality of RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((""""CCCC"""")))).
  412.  
  413.               static const RWLocale&
  414.           gggglllloooobbbbaaaallll();
  415.  
  416.  
  417.      Returns a reference to the present global "default" locale.
  418.  
  419.               const RWLocale*
  420.           ddddeeeeffffaaaauuuullllttttLLLLooooccccaaaalllleeee();
  421.  
  422.  
  423.      Returns a pointer to a new instance of either RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((""""CCCC"""")))); or
  424.      another class that provides the same behavior for compilers that don't
  425.      fully support Standard C locales.
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.